package com.jy.adscm.zltx.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.bean.system.JyDept;
import com.jy.adscm.system.mapper.mysql.JyDeptMapper;
import com.jy.adscm.zltx.bean.QsQsfileDept;
import com.jy.adscm.zltx.mapper.mysql.QsQsfileDeptMapper;
import com.jy.adscm.zltx.service.QsQsfileDeptService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2018-11-02
 */
@Service
public class QsQsfileDeptServiceImpl extends ServiceImpl<QsQsfileDeptMapper, QsQsfileDept> implements QsQsfileDeptService {
@Autowired
    JyDeptMapper jyDeptMapper;
@Autowired
QsQsfileDeptMapper qsQsfileDeptMapper;

    @Override
    public List<QsQsfileDept> selectByFileId(Integer fileId) {
        Wrapper <QsQsfileDept> wrapper =new EntityWrapper<>();
        wrapper.eq("fileId",fileId);
        List<QsQsfileDept> qsQsfileDepts = qsQsfileDeptMapper.selectList(wrapper);
        List<QsQsfileDept> newqsQsfileDepts=new ArrayList<>();
        for (QsQsfileDept qsQsfileDept : qsQsfileDepts) {
            if (qsQsfileDept.getDeptId()!=null){
                JyDept jyDept = jyDeptMapper.selectById((qsQsfileDept.getDeptId()));
                 qsQsfileDept.setDeptName(jyDept.getDeptName());
                newqsQsfileDepts.add(qsQsfileDept);
            }

        }
        return newqsQsfileDepts;
    }
}
